package com.solcoo.customer.ui.find;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.common.image.ImageLoader;
import com.solcoo.customer.R;
import com.solcoo.customer.base.BaseListAdapter;
import com.solcoo.customer.model.Shop;

public class FindAdapter extends BaseListAdapter<Shop> {

	public FindAdapter(Context context) {
		super(context);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView != null) {
			holder = (ViewHolder) convertView.getTag(R.layout.find_item);
		} else {
			holder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.find_item, null);
			holder.shopIcon = (ImageView) convertView
					.findViewById(R.id.shop_icon);
			holder.shopName = (TextView) convertView
					.findViewById(R.id.shop_name);
			holder.shopAddress = (TextView) convertView
					.findViewById(R.id.shop_address);
			convertView.setTag(R.layout.find_item, holder);
		}

		Shop shop = getItem(position);
		ImageLoader.getInstance().load(shop.touxiang, holder.shopIcon);
		holder.shopName.setText(shop.dianming);
		holder.shopAddress.setText(shop.dizhi);
		convertView.setContentDescription(shop.yonghum);
		return convertView;
	}

	private class ViewHolder {
		public ImageView shopIcon;
		public TextView shopName;
		public TextView shopAddress;
	}

}
